<template>
  <div class="search">
    <el-card>
    <el-row v-for="c in contentArr" style="padding: 12px 0">
      <el-col span="8" style="height:145px;">
        <img :src="c.articleSearchVO.contentImgUrl" style="height:145px;width:258px;">
      </el-col>
      <el-col span="16" style="height:145px;position: relative">
        <a :href="'/detail?id='+c.articleSearchVO.id">
          <p style="color:black;text-align: left;font-size:16px;font-weight: bold;margin-top:0;" v-html="c.title[0]==null?c.articleSearchVO.title:c.title[0]"></p>
          <p v-html="c.articleSearchVO.brief" style="color:#666;font-size:10px;text-align: left;line-height: 20px;"></p>
        </a>
        <div style="position: absolute;bottom: 10px">
        <i style="font-size:13px;" class="el-icon-location-outline">{{c.articleSearchVO.ip}}</i>
        <el-avatar :size="20" :src="c.articleSearchVO.userImgUrl" style="margin:6px 5px -5px 40px;"></el-avatar>
        <span style="font-size: 13px;color:#ff6e6e">{{c.articleSearchVO.nickName}}</span>
        <i @click="collect()" style="font-size:14px;margin-left: 50px;" class="el-icon-star-off">{{c.articleSearchVO.collectCount}}</i>
        <i style="font-size:14px;margin-left: 50px;" class="el-icon-chat-dot-square">{{c.articleSearchVO.commentCount}}</i>
        <i style="font-size:14px;margin-left: 50px;" class="el-icon-sugar">{{c.articleSearchVO.upCount}}</i>
        <i style="font-size:14px;margin-left: 50px;" class="el-icon-view">{{c.articleSearchVO.viewCount}}</i>
        </div>
      </el-col>
    </el-row>
  </el-card>
  </div>
</template>

<script>
export default {
  name: "HotView",
  data:function (){
    return{
      contentArr:[],

    }
  },
  methods:{
    collect(){
      this.axios.post("http://localhost:8080/v1/contents/collect").then((response)=> {

      })
    },
  },
  created:function (){
    let textSearch = this.$router.currentRoute.query.textSearch;
    if (!textSearch) {
     location.href="/community/hot"
    }
    this.axios
        .create({
          'headers':{
            'Authorization': localStorage.getItem('localJwt')
          }
        })
        .get("http://localhost:8080/v1/contents/"+textSearch+"/search").then((response)=> {
      if (response.data.code==1){
        this.contentArr = response.data.data;
      }else{
        this.$message.error(response.data.msg);
        this.$router.push('/community/all')
      }
    })
  }
}
</script>

<style scoped>

</style>